<?php
$periode_gaji_id=get_periode_gaji() ;
if($periode_id==0){
	$periode_id=$periode_gaji_id; 
}	
$last_periode_id=get_last_periode_id($periode_id) ;
if( $periode_gaji_id==$periode_id ){
	$kalkulasi_periode=0;
}else{
	$kalkulasi_periode=$periode_id;
}
$karyawan = loaddata_karyawan($karyawan_id);
$jabatan_id = isset( $karyawan['jabatan_id'] ) ? $karyawan['jabatan_id'] :  0;
$jabatan =  loaddata_jabatan( $jabatan_id);  
$gajis =  get_gaji($karyawan_id, $kalkulasi_periode);
$golongan_jabatan = my_get_data_by_id('golongan_jabatan','golongan_jabatan_id',$jabatan['golongan_jabatan_id']);


	function get_gaji($karyawan_id , $kalkulasi_periode){ 
		$query = " SELECT * FROM pr_gaji 
			WHERE periode_id={$kalkulasi_periode}
			AND karyawan_id={$karyawan_id}"
		;
		$result = my_query($query);	
		$datas = my_fetch_array($result);	
		return $datas;
	}
 
	
	function get_data_list($karyawan_id , $kalkulasi_periode, $jenis){

		$query = "SELECT a.komponen_id,a.kalkulasi  
				FROM pr_gaji_komponen a 
				LEFT JOIN pr_komponen_gaji b ON a.komponen_id=b.komponen_gaji_id
				WHERE a.periode_id={$kalkulasi_periode} 
				AND a.karyawan_id={$karyawan_id} 
				AND b.tipe={$jenis} 
				AND a.kalkulasi<>0 
				ORDER BY a.komponen_id" ;

		$rs = my_query($query);
		$datas = array();
		while($row = my_fetch_array($rs)){
			$datas[$row['komponen_id']] = $row['kalkulasi'];
		}
		return $datas;
	}

	function get_data_rapel($komponen_id , $karyawan_id , $prev_periode_id){
		$query = "
				SELECT nominal FROM pr_rapel_komponen_karyawan 
				WHERE periode_prev_id	= {$prev_periode_id}
					AND komponen_id	={$komponen_id} 
					AND karyawan_id	={$karyawan_id}";
		$result = my_query($query);
		$row = my_fetch_array($result);
		return $row['nominal'];
	}
	
	function ottime($karyawan_id, $periode_id){

		$query = "SELECT IF(lembur_lebih56jam = 'Y' ,hourpay_56,hourpay ) AS fdata
			FROM a_absen_payroll 
		WHERE karyawan_id ={$karyawan_id} 
		AND periode_id={$periode_id}
		LIMIT 1
		";
		
		$res = my_query($query);
		$row = my_fetch_array($res);
		 
		return $row['fdata'];
	}

	function get_periode_gaji_label($periode_id){
		
		$periode = my_get_data_by_id('pr_periode','periode_id',$periode_id);
		$bulan = array(
				'01'=>'Januari',
				'02'=>'Februari',
				'03'=>'Maret',
				'04'=>'April',
				'05'=>'Mei',
				'06'=>'Juni',
				'07'=>'Juli',
				'08'=>'Agustus',
				'09'=>'September',
				'10'=>'Oktober',
				'11'=>'Nopember',
				'12'=>'Desember',
			);
		$periode_bulan = date( 'm', strtotime($periode['tanggal']));	
		return $bulan[$periode_bulan].' '.$periode['tahun'];
	} 

?>

<style type="text/css">
<!--

	table.page_header {width: 100%; border: none; background-color: #CDCDCD; border-bottom: solid 1mm #000; padding: 2mm }
	table.page_footer {width: 100%; border: none;  border-top: solid 1mm #000; padding: 2mm}
	table.td {font-size:10px;}
div.zone
{
	border: solid 2mm #66AACC;
	border-radius: 3mm;
	padding: 1mm;
	background-color: #FFEEEE;
	color: #440000;
}
div.zone_over
{
	width: 30mm;
	height: 35mm;
	overflow: hidden;
}

-->
</style>
<div style="width: 100%; text-align:center; font-size: 11pt ;">   
P T . &nbsp; K R A K A T A U &nbsp; M E D I K A<br>
SLIP GAJI ( <?php echo strtoupper(get_periode_gaji_label($periode_id)); ?> )
<br>
<br> 
<br>
</div>
	<table style="width: 100%;" align="center">
		<tr> 
			<td style="vertical-align: top; padding: 2px; width: 15%; text-align: left;">
			NIK
			</td>
			<td style="vertical-align: top; padding: 2px; width: 35%; text-align: left;"> 
			: <?php echo $karyawan['nik']; ?></td>
			<td style="vertical-align: top; padding: 2px; width: 15%; text-align: left;"> 
			T.M.B
			</td>
			<td style="vertical-align: top; padding: 2px; width: 35%; text-align: left;"> 
			: <?php echo date('d - m - Y',strtotime($karyawan['tmb'])); ?>
			</td>
		</tr> 
		<tr> 
			<td style="vertical-align: top; padding: 2px; width: 15%; text-align: left;">
			St. Karyawan
			</td>
			<td style="vertical-align: top; padding: 2px; width: 35%; text-align: left;"> 
			: <?php 
			 
			echo $karyawan['status_karyawan']; ?>  </td>
			<td style="vertical-align: top; padding: 2px; width: 15%; text-align: left;"> 
			St. Kel
			</td>
			<td style="vertical-align: top; padding: 2px; width: 35%; text-align: left;">
			 :   <?php if($karyawan['ptkp_status'] == 'TK'){ echo 'TK'; }else{ echo 'K/'.$karyawan['ptkp_tanggung']; } ?>
			</td>
		</tr>
		<tr> 
			<td style="vertical-align: top; padding: 2px; width: 15%; text-align: left;">
			Dep/CCC
			</td>
			<td style="vertical-align: top; padding: 2px; width: 35%; text-align: left;"> 
			: <?php 
			$pbi = my_get_data_by_id('pos_biaya','pos_biaya_id',$jabatan['pos_biaya_id']);
			echo substr($jabatan['organisasi_departemen'] , 0,12); ?> /  <?php echo $pbi['code'];?></td>
			<td style="vertical-align: top; padding: 2px; width: 15%; text-align: left;"> 
			Jabatan
			</td>
			<td style="vertical-align: top; padding: 2px; width: 35%; text-align: left;"> 
			:  <?php echo $jabatan['nama_jabatan']; ?>
			</td>
		</tr>
 		<tr> 
			<td style="vertical-align: top; padding: 2px; width: 15%; text-align: left;">
			Nama
			</td>
			<td colspan="3" style="vertical-align: top; padding: 2px; width: 35%; text-align: left;"> 
			:  <?php echo $karyawan['nama_gelar']; ?></td>
			  
		</tr>  
	</table> 
	<hr>
	<table style="width: 100%;" align="center">
		<tr> 
			<td style="vertical-align: top; padding: 2px; width: 65%; text-align: left;">
			
			Klasifikasi golongan : <?php echo $golongan_jabatan['kode_golongan_jabatan']; ?>   
			</td>
			<td style="width:5%"> Grade:</td>
			<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
				 <?php //echo rp_format($gajis['gapok_km']) ;
				  echo str_pad($karyawan['grade_id'],2); ?> 
			</td>
		</tr> 
	</table>
	<table style="width: 100%;" align="center">
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
			A.
			</td>
			<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
			<b>Gaji dibayarkan</b>
			</td>
			<td style="width:5%">:Rp.</td>
			<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
			<?php echo rp_format($gajis['gaji_dibayar']);?></td>
 		</tr>
		<?php 
		$rapel_gaji = get_data_rapel(0 , $karyawan_id , $last_periode_id);
		if( $rapel_gaji > 0 ): ?>
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
			&nbsp;
			</td>
			<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
			 Rapel gaji 
			</td>
			<td style="width:5%">:Rp.</td>
			<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
			<?php echo rp_format($rapel_gaji);?></td>
 		</tr>
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
			&nbsp;
			</td>
			<td style="border-top:1px solid;vertical-align: top; padding: 2px; width: 60%; text-align: left;">
			 Total gaji 
			</td>
			<td style="border-top:1px solid;width:5%">:Rp.</td>
			<td style="border-top:1px solid;vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
			<?php echo rp_format($rapel_gaji + $gajis['gaji_dibayar']);?></td>
 		</tr>
		<?php endif; ?>
	</table>
	<br>
	<table style="width: 100%;" align="center">
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
			B.
			</td>
			<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
			<b>Tunjangan</b>
			</td>
			<td style="width:5%">&nbsp;</td>
			<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
			&nbsp;
			</td>
 		</tr>
		<?php 
		$komponens = get_data_list($karyawan_id, $kalkulasi_periode , '1');
		$tunjangan_total += array_sum($komponens);
		if(is_array($komponens)){
			foreach($komponens as $komponen_id => $rupiah ){
			?>
			<tr>
				<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
				&nbsp;
				</td>
				<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
				 <?php 
				$kom = my_get_data_by_id('pr_komponen_gaji','komponen_gaji_id',$komponen_id);
				echo $kom['nama_komponen_gaji']; ?> 
				</td>
				<td style="width:5%">: Rp.</td>
				<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
				<?php echo rp_format($rupiah); ?>
				</td>
			</tr>
			<?php 
				$nominal_rapel = get_data_rapel($komponen_id , $karyawan_id , $last_periode_id);
				if( $nominal_rapel <> 0 ){
			?>		
			<tr>
				<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
				&nbsp;
				</td>
				<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
				<?php 
				$kom = my_get_data_by_id('pr_komponen_gaji','komponen_gaji_id',$komponen_id);
				echo 'Rapel '.$kom['nama_komponen_gaji']; ?> 
				</td>
				<td style="width:5%">: Rp.</td>
				<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
				<?php echo rp_format($nominal_rapel); 
				$tunjangan_total += $nominal_rapel;
				?>
				</td>
			</tr>
			<?php
				}
			}
		}
		?>
		 
		<tr>
		<td>&nbsp;</td>
		<td style="border-top:1px solid;text-align:left;">Total Tunjangan</td> 
		<td style="border-top:1px solid;text-align:left;">&nbsp;Rp.</td> 
		<td style="border-top:1px solid;text-align:right;"><?php echo rp_format($tunjangan_total);?></td></tr>
	</table>
	<br>
	<table style="width: 100%;" align="center">
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
			C.
			</td>
			<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
			<b>Potongan</b>
			</td>
			<td style="width:5%">&nbsp;</td>
			<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
			&nbsp;
			</td>
 		</tr>
		<?php 
		$komponens = get_data_list($karyawan_id, $kalkulasi_periode , '2');
		$potongan_total = array_sum($komponens)*-1;
		$total_potong = 0;
		if(is_array($komponens)){
			foreach($komponens as $komponen_id => $rupiah ){
			$total_potong += $rupiah;
			?>
			<tr>
				<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
				&nbsp;
				</td>
				<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
				 <?php 
				$kom = my_get_data_by_id('pr_komponen_gaji','komponen_gaji_id',$komponen_id);
				echo $kom['nama_komponen_gaji']; ?> 
				</td>
				<td style="width:5%">: Rp.</td>
				<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
				<?php echo rp_format($rupiah*-1); ?>
				</td>
			</tr>
			<?php 
				$nominal_rapel = get_data_rapel($komponen_id , $karyawan_id , $last_periode_id);
				if( $nominal_rapel <> 0 ){
			?>		
			<tr>
				<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
				&nbsp;
				</td>
				<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
				<?php 
				$kom = my_get_data_by_id('pr_komponen_gaji','komponen_gaji_id',$komponen_id);
				echo 'Rapel '.$kom['nama_komponen_gaji']; ?> 
				</td>
				<td style="width:5%">: Rp.</td>
				<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
				<?php echo rp_format($nominal_rapel); 
				$potongan_total += ($nominal_rapel * -1);
				$total_potong +=  $nominal_rapel * -1; 
				 ?>
				</td>
			</tr>
			<?php
				}
			}
		}
		?>
		 
		<tr>
		<td>&nbsp;</td>
		<td style="border-top:1px solid;text-align:left;">Total Potongan</td> 
		<td style="border-top:1px solid;text-align:left;">&nbsp;Rp.</td> 
		<td style="border-top:1px solid;text-align:right;"><?php echo rp_format($total_potong * -1);  ?></td></tr>
	</table>
	<br>
	<table style="width: 100%;" align="center">
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
			D.
			</td>
			<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
			<b>Iuran</b>
			</td>
			<td style="width:5%">&nbsp;</td>
			<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
			&nbsp;
			</td>
 		</tr>
		<?php 
		$komponen_id=1;
		$komponens = get_data_list($karyawan_id, $kalkulasi_periode , '3');
		$tp_total = array_sum($komponens);
		if(is_array($komponens)){
			foreach($komponens as $komponen_id => $rupiah ){
			?>
			<tr>
				<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
				&nbsp;
				</td>
				<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
				 <?php 
				$kom = my_get_data_by_id('pr_komponen_gaji','komponen_gaji_id',$komponen_id);
				echo $kom['nama_komponen_gaji']; ?> 
				</td>
				<td style="width:5%">: Rp.</td>
				<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
				<?php echo rp_format($rupiah); ?>
				</td>
			</tr>
			<?php
				$nominal_rapel = get_data_rapel($komponen_id , $karyawan_id , $last_periode_id);
				if( $nominal_rapel <> 0 ){
			?>		
			<tr>
				<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
				&nbsp;
				</td>
				<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
				<?php 
				$kom = my_get_data_by_id('pr_komponen_gaji','komponen_gaji_id',$komponen_id);
				echo 'Rapel '.$kom['nama_komponen_gaji']; ?> 
				</td>
				<td style="width:5%">: Rp.</td>
				<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
				<?php echo rp_format($nominal_rapel  ); 
				$tp_total += $nominal_rapel ;?>
				</td>
			</tr>
			<?php
				}			
			}
		}
		?>
		 
		<tr>
		<td>&nbsp;</td>
		<td style="border-top:1px solid;text-align:left;">Total Iuran</td> 
		<td style="border-top:1px solid;text-align:left;">&nbsp;Rp.</td> 
		<td style="border-top:1px solid;text-align:right;"><?php echo rp_format($tp_total);?></td></tr>
	</table>
	<br>
	<table style="width: 100%;" align="center">
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 5%; text-align: center;">
			E.
			</td>
			<td style="vertical-align: top; padding: 2px; width: 60%; text-align: left;">
			<b>Diterima</b> (  A  +  B  -  C )
			</td>
			<td style="width:5%">Rp.</td>
			<td style="vertical-align: top; padding: 2px; width: 30%; text-align: right;"> 
			<?php echo rp_format($gajis['gaji_dibayar'] + $rapel_gaji + $tunjangan_total + $total_potong);?>
			</td>
 		</tr>
	</table>
  
 
HRIS Krakatau Medika (c) 2011 - <?php echo date('Y'); ?>
 